package com.iflysse.services.impl;

import com.iflysse.mapper.KnowLedgePointMapper;
import com.iflysse.mapper.KnowLedgePointMapper;
import com.iflysse.pojo.bo.resp.KnowledgePointBoResp;
import com.iflysse.pojo.bo.resp.KnowledgePointListBoResp;
import com.iflysse.pojo.po.resp.KnowledgePointPoResp;
import com.iflysse.services.IKnowledgePointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @author fengjunfei
 * @date 2021/10/25 11:25
 */
@Service
public class KnowledgePointServiceImpl implements IKnowledgePointService {

    @Autowired
    KnowLedgePointMapper knowledgePointMapper;

    @Override
    public KnowledgePointListBoResp listAllKnowledgePoints() {
        //从数据库中获取所有的知识点
        List<KnowledgePointPoResp> allKnowledgePoints = knowledgePointMapper.getAllKnowledgePoints();
        KnowledgePointListBoResp knowledgePointListBoResp = new KnowledgePointListBoResp();

        knowledgePointListBoResp.setKnowledgePointBoRespList(new ArrayList<>());
        allKnowledgePoints.forEach(knowledgePointPoResp -> {
            KnowledgePointBoResp knowledgePointBoResp = new KnowledgePointBoResp(knowledgePointPoResp.getKnowledgePointId());
            knowledgePointListBoResp.getKnowledgePointBoRespList().add(knowledgePointListBoResp);
        });
        return knowledgePointListBoResp;
    }

}